/**
 * Created by Administrator on 2017/11/29.
 */
import {insertSystemConfig,querySystemConfig,updateSystemConfig} from '../services/adminManageApi';
export default{
    namespace:'systemConfig',
    state:{
        submitting:false,
        loading:false,
        data:{
            list:[],
            pagination:{},
        },
    },
    effects:{
        // *insertSystemConfig({payload,callback},{put,call}){
        //     yield put({
        //         type:'changeSubmitting',
        //         payload:true
        //     });
        //     const response=yield call(insertSystemConfig,payload);
        //     yield put({
        //         type:'handleResponse',
        //         payload:response,
        //     });
        //     yield put({
        //         type:'changeSubmitting',
        //         payload:false,
        //     })
        //     if(callback)callback(response);
        // },
        *querySystemConfig({payload},{put,call}){
            yield put({
                type:'changeLoading',
                payload:true,
            });
            const queryParam=yield  call(querySystemConfig,payload);
            yield put({
                type:'handleQueryParam',
                payload:queryParam,
            })
            yield put({
                type:'changeLoading',
                payload:false,
            });
        },
        // *updateSystemConfig({payload,callback},{put,call}){
        //     yield put({
        //         type:'changeSubmitting',
        //         payload:true
        //     });
        //     const response=yield call(updateSystemConfig,payload);
        //     yield put({
        //         type:'handleResponse',
        //         payload:response,
        //     });
        //     yield put({
        //         type:'changeSubmitting',
        //         payload:false,
        //     })
        //     if(callback)callback(response);
        // }
    },
    reducers:{
        changeSubmitting(state,{payload}){
            return({
                ...state,
                submitting:payload,
            })
        },
        handleResponse(state,{payload}){
            return ({
                ...state,
                result:payload.result,
            })
        },
        handleUpdate(state,{payload}){
            return ({
                ...state,
            })
        },
        changeLoading(state,{payload}){
            return ({
                ...state,
                loading:payload,
            })
        },
        handleQueryParam(state,{payload}){

            return ({
                ...state,
                data:payload.resultData.systemParam,

            })
            console.log(payload.resultData.systemParam);
        }
    },
};